<?php
/**
 * Created by PhpStorm.
 * User: Admin
 * Date: 2018/7/23
 * Time: 20:51
 */
namespace fast;

require_once '../vendor/aip-php-sdk-2.2.5/AipNlp.php';

class BaiduNlp{
    const APP_ID='11574830';
    const API_KEY='WKz2GcZMLPGwcCitUyTMNk7I';
    const SECRET_KEY='IvWe2rBtHfd3vR8Rukh3Knm2KsEuModr';

    private $client;

    public function __construct()
    {
        $this->client= new \AipNlp(self::APP_ID, self::API_KEY, self::SECRET_KEY);
    }

    //词法分析
    public function get_lexer($text)
    {
        return $this->client->lexer($text);
    }

    // 调用依存句法分析
    public function depParser($text)
    {
        // 如果有可选参数
        $options = array();
        $options["mode"] = 1;

        return $this->client->depParser($text,$options);
    }

    //调用情感倾向分析
    public function sentiment($text)
    {
        return $this->client->sentimentClassify($text);
    }

    //调用文章标签
    public function keyword($title,$content)
    {
        return $this->client->keyword($title,$content);
    }

    //调用文章分类
    public function auto_cate($title,$content)
    {
        return $this->client->topic($title,$content);
    }
}